Skip to content

feat: Add resource_type_slug to createOrganizationRole to create resource-scoped custom roles#1549

Open
atainter wants to merge 1 commit intomainfrom
at-add-custom-fga-role-support
Open

feat: Add resource_type_slug to createOrganizationRole to create resource-scoped custom roles#1549
atainter wants to merge 1 commit intomainfrom
at-add-custom-fga-role-support

Conversation

@atainter
Copy link
Copy Markdown
Contributor

Also makes permission slug optional. If omitted, the service will create auto-generated slugs

@atainter atainter requested review from a team as code owners April 10, 2026 23:01
@atainter atainter requested a review from mattgd April 10, 2026 23:01
@atainter atainter changed the title Add resource_type_slug to createOrganizationRole to create resource-scoped custom roles feat: Add resource_type_slug to createOrganizationRole to create resource-scoped custom roles Apr 10, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR makes slug optional in CreateOrganizationRoleOptions (allowing the service to auto-generate slugs) and adds resourceTypeSlug to support resource-scoped custom organization roles. The changes are minimal, follow the existing pattern established by createEnvironmentRole, and are covered by two new tests.

Confidence Score: 5/5

Safe to merge — changes are small, consistent with existing patterns, and well-tested.

No P0/P1 findings. The serializer correctly relies on JSON.stringify to strip undefined optional fields. The interface changes are backward-compatible (making a required field optional is non-breaking). Tests cover both new behaviors.

No files require special attention.

Important Files Changed

Filename Overview
src/authorization/interfaces/create-organization-role-options.interface.ts Makes slug optional and adds resourceTypeSlug/resource_type_slug to both the input and serialized interfaces — consistent with the environment role counterpart.
src/authorization/serializers/create-organization-role-options.serializer.ts Adds resource_type_slug: options.resourceTypeSlug mapping; undefined values are stripped by JSON.stringify, so omitting optional fields is handled correctly.
src/authorization/authorization.spec.ts Adds two tests covering the new resourceTypeSlug field and optional slug; fixtures and assertions align correctly with the serializer and deserializer behavior.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant SDK as WorkOS SDK
    participant Serializer as serializeCreateOrganizationRoleOptions
    participant API as WorkOS API

    Caller->>SDK: createOrganizationRole(orgId, { name, slug?, resourceTypeSlug? })
    SDK->>Serializer: serialize options
    Note over Serializer: Maps resourceTypeSlug → resource_type_slug<br/>Strips undefined fields via JSON.stringify
    Serializer-->>SDK: { name, slug?, resource_type_slug? }
    SDK->>API: POST /authorization/organizations/{orgId}/roles
    API-->>SDK: OrganizationRoleResponse (with resource_type_slug)
    SDK->>SDK: deserializeOrganizationRole() resource_type_slug → resourceTypeSlug
    SDK-->>Caller: OrganizationRole
Loading

Reviews (1): Last reviewed commit: "Add resource_type_slug to createOrganiza..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant